package pecan.ui;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.DefaultCellEditor;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;

public class AddAction extends JDialog {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private final JPanel contentPanel = new JPanel();
	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTable table;
	private String[] types = new String[] {"Byte", "Character", "Short", "Int", "Long", "Float", "Double", "String"};

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			AddAction dialog = new AddAction();
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public AddAction() {
		setBounds(100, 100, 376, 300);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JLabel lblId = new JLabel("Id:");
			lblId.setBounds(10, 10, 54, 15);
			contentPanel.add(lblId);
		}
		{
			JLabel lblAction = new JLabel("Action:");
			lblAction.setBounds(10, 35, 54, 15);
			contentPanel.add(lblAction);
		}
		{
			JLabel lblActionMethod = new JLabel("Action Method:");
			lblActionMethod.setBounds(10, 60, 93, 15);
			contentPanel.add(lblActionMethod);
		}
		{
			JLabel lblParams = new JLabel("Params:");
			lblParams.setBounds(10, 85, 54, 15);
			contentPanel.add(lblParams);
		}
		
		textField = new JTextField();
		textField.setBounds(97, 7, 261, 21);
		contentPanel.add(textField);
		textField.setColumns(10);
		
		textField_1 = new JTextField();
		textField_1.setBounds(97, 32, 261, 21);
		contentPanel.add(textField_1);
		textField_1.setColumns(10);
		
		textField_2 = new JTextField();
		textField_2.setBounds(97, 57, 261, 21);
		contentPanel.add(textField_2);
		textField_2.setColumns(10);
		
		JPanel panel = new JPanel();
		panel.setBounds(97, 88, 261, 135);
		contentPanel.add(panel);
		panel.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane = new JScrollPane();
		panel.add(scrollPane, BorderLayout.CENTER);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
				{null, null},
			},
			new String[] {
				"\u7C7B\u578B", "\u503C"
			}
		));
		table.getColumnModel().getColumn(0).setCellEditor(new DefaultCellEditor(new JComboBox(types)));
		scrollPane.setRowHeaderView(table);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				JButton okButton = new JButton("OK");
				okButton.setActionCommand("OK");
				buttonPane.add(okButton);
				getRootPane().setDefaultButton(okButton);
			}
			{
				JButton cancelButton = new JButton("Cancel");
				cancelButton.setActionCommand("Cancel");
				buttonPane.add(cancelButton);
			}
		}
	}
}
